< previous page page_673 next page >

Page 673
9f31265bb40b592b1929e18a47ab28e5.gif
   For lngLoop = 0 To conRepeats
      vntValue = vntValue + 1
      vntValue = vntValue - 1
   Next
   ' Stop timer for "Slow" method
   oTimer.Quit1
   Debug.Print "Elapsed 1: " & oTimer.ElapsedTime1

   ' Start timer for "Fast" method
   oTimer.Start2
   ' Perform the "Fast" method
   For lngLoop = 0 To conRepeats
      lngValue = lngValue + 1
      lngValue = lngValue - 1
   Next
   ' Stop timer for "Fast" method
   oTimer.Quit2
   Debug.Print "Elapsed 2: " & oTimer.ElapsedTime2 & vbCrLf

   ' Add Time to list box
   lstTimes.AddItem mstrTestName & vbTab & _
                                   oTimer.Percent
End Sub
Avoid the Use of Variant Data Types
The Variant data type takes many bytes to store; therefore, its much larger in memory than other data types. Also, it takes longer to read from and write to a Variant variable. For these reasons, you should always strive to use other data types before using the type Variant. In my tests using Long integers instead of Variant data types, the results were that the Long integers were accessed over 55 percent faster than the Variant data types.
Integer Versus Long Data Types
The results for whether to use an Integer or a Long were very inconclusive. In most instances, Integer and Long data types were both accessed quickly. An Integer is only two bytes in memory, whereas a Long is four bytes; therefore, an Integer should be slightly faster to access, but its not as big a difference as accessing a Variant.

 
< previous page page_673 next page >

If you like this book, buy it!